<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common.jsp" %>
<div class="pageHeader">
		<fieldset>
			<legend>用户信息</legend>
			<p>
				<label>登录账号：${entity.loginName }</label>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<label>真实姓名：${entity.realName }</label>
			</p>
		</fieldset>
	</div>
<div class="pageContent" >
	<form id="form" method="post" action="${ctxPath}/sys/sysUser/assignRole" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
		<input type="hidden" name="navTabId" value="jsgl">
		<input type="hidden" name="callbackType" value="closeCurrent">
		<input type="hidden" name="id" value="${entity.id }" />
		<input type="hidden" name="selectVal" id="selectVal" value="">
		<div class="pageFormContent"  layoutH="111">
			<table class="table" targetType="navTab" asc="asc" desc="desc" width="100%">
				<thead>
					<tr>
						<th>序号</th>
						<th>角色名称</th>
						<th>描述</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach var="item" items="${roleList}" varStatus="st">
						<tr target="sid_user" rel="${item.id}">
							<td><input type="checkbox" name="roleId" value="${item.id}" <c:if test="${item.status==1}">checked="checked"</c:if> />${st.index+1}</td>
							<td>${item.name }</td>
							<td>${item.description}</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		<div class="formBar">
			<ul>
				<li><div class="button"><div class="buttonContent"><button type="button" class="checkboxCtrl" group="roleId" selectType="all">全选</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="button" class="checkboxCtrl" group="roleId" selectType="invert">反选</button></div></div></li>
				<li><div class="buttonActive"><div class="buttonContent"><button type="button"  onclick="submitForm()" >保存</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
function submitForm() {
	var str = "";
	//获取所有的可以选择的资源
	$("input:checkbox[name=roleId]").each(function() {
		//console.info($(this).is(':checked'));
		//判断是否被选中
		if($(this).is(':checked')){
			str += $(this).val() + ",";
		}
	});
// 	alert(str);
	$("#selectVal").val(str);
	$("#form").submit();
}
</script>
